﻿using AbpEntityFrameworkcore.DbContext;
using AbpToDomain.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpApplication.Expand
{
    public class QueryDynamic_View_TaskOrder
    {

        private readonly MyDbContext context;

        public QueryDynamic_View_TaskOrder(MyDbContext context)
        {
            this.context = context;
        }

        public List<View_TaskOrder> QueryDynameic(string? BoxCode, string? Type,

            string? OrderNo,string? State)
        {
            IQueryable<View_TaskOrder> view_TaskOrders = context.View_TaskOrders;
            if (!string.IsNullOrEmpty(BoxCode))
            {
                view_TaskOrders = view_TaskOrders.Where(b => b.BoxCode.Contains(BoxCode));
            }
            if (!string.IsNullOrEmpty(Type))
            {
                view_TaskOrders = view_TaskOrders.Where(b => b.Type.Contains(Type));
            }
            if (!string.IsNullOrEmpty(OrderNo))
            {
                view_TaskOrders = view_TaskOrders.Where(b => b.OrderNo.Contains(OrderNo));
            }
            if (!string.IsNullOrEmpty(State))
            {
                view_TaskOrders = view_TaskOrders.Where(b => b.State.Contains(State));
            }

            return view_TaskOrders.ToList();
        }

    }
}
